
        // slideshows
      $(function() {
        $('.post-body a').contents().unwrap();
        $('.fader').prepend("<ul class='pager_list'><span class='slideCounter'></span></ul>").append("<div class='page prev' data-target='prev'>&lsaquo;</div><div class='page next' data-target='next'>&rsaquo;</div>");
      });




      $(function() {
        $(window).scroll(function() {
          // resize posts 
          var a = $(window).scrollTop();
          var b = $('#sidebarAnchor').offset().top;
          if (a > b) {
            $('#HTML6').css({width: '1200px'});
          } else {
            $('#HTML6').css({width: '100%'});
          }
          // fixedRandoms
          var e = $(window).scrollTop();
          var f = $('#sidebarAnchor').offset().top;
          if (e > f) {
            $('#HTML4').addClass('fixedRandoms');
          } else {
            $('#HTML4').removeClass('fixedRandoms');
          }
        });   
		// add URL to facebook comments
        $(".fcomments").attr('href',window.location.href);
        // close pop-ups
        $(".closer").click(function(){
          $(this).parent().fadeOut();
        });
        // handle GIF pictures
        $(".postable img").each(function() {
          var height = $(this).height();
          if(height>1500) {
            $(this).addClass('gif');
          }
          if( $(this).attr('src').match(/\.(gif)/) ) {
            $(this).addClass('gif');
          }
        });
        // remove titles images 
        $('.theBody img').removeAttr('title');
        // optimize images
        $('.mobile .content-outer, .content-outer, .moreBits').find('img').each(function(n, image){
          var image = $(image);
          image.attr({src : image.attr('src').replace(/s\B\d{2,4}/,'s0')});
          image.removeAttr('width').removeAttr('height');
        });
        // show contact form
        $('#contactToggler').click(function(){
          $('.contact').fadeToggle();
        });
      });
      // encourage facebook posting
      $(function() {
        $( ".postable img" ).wrap( "<div class='imgToPost'></div>" );
        $('.postable img:not(.gif)').hover(
          function(){
            $(this).before("<div class='postIt-wrapper'><div class='postIt'>Post this photo on Facebook</div></div>"),
              $(this).css('border', '1px solid #3F60A5')
          },
          function(){
            $( "div.postIt-wrapper" ).remove(),
              $(this).css('border', '1px solid #DBDBDB')
          });
      });
      // posting pictures events
      function confirmPost() {
        $(".confirmScreen").fadeIn('slow').delay(3000).fadeOut('slow');
        $(".photo-uploader").delay(1000).fadeOut();
      }
      function cancel(){
        $('.photo-uploader').fadeOut();
        $('#mainTeaser').fadeOut();
      }
      $(function(){
        FB.getLoginStatus(function(response) {
          if (response.status == 'connected') {
            // logged in and authorized app
            var user_id = response.authResponse.userID;
            var page_id = "572737262765971"; 
            var fql_query = "SELECT uid FROM page_fan WHERE page_id="+page_id+" and uid="+user_id;
            // user details
            $userId = response.authResponse.userID;
            $('#userThumb').prepend("<img src='http://graph.facebook.com/"+$userId+"/picture?type=square'/>");
            FB.api('/me', function(response) {
              $('#userThumb').append(response.first_name);                
            });
            // query
            FB.api({
              method: 'fql.query',
              query: fql_query
            },
                   function(response){
                     if (response[0]) {
                       // liked
                       //   $('.like-button.post').show();
                     } else {
                       // not liked
                       //      showLikeBox();
                       //  $('.like-button.page').show();
                     }
                   }
                  );    
          } else if (response.status === 'not_authorized') {
            // not_authorized
            $("#secondaryTeaser").show("slow");
            showTeaser();
          } 
            else  {
              // not_logged_in
              $("#secondaryTeaser").show("slow");
              showTeaser();
            } 
        });
        $('.like-button.post').show();
      });